//! 希腊字母专项演示

use unichar::{Unichar, Config, Style};

fn main() {
    println!("=== 希腊字母专项演示 ===\n");

    let mut unichar = Unichar::new();
    unichar.set_config(Config::new().with_style(Style::Simple));

    // 1. 小写希腊字母
    println!("1. 🔤 小写希腊字母:");
    let lowercase_greek = [
        "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta",
        "iota", "kappa", "lambda", "mu", "nu", "xi", "omicron", "pi",
        "rho", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega"
    ];
    
    println!("   字母名称 -> 符号");
    for (i, char_name) in lowercase_greek.iter().enumerate() {
        if let Some(char) = unichar.get(char_name) {
            print!("   {:>10} -> {}  ", char_name, char);
            if (i + 1) % 4 == 0 {
                println!();
            }
        }
    }
    println!("\n");

    // 2. 大写希腊字母
    println!("2. 🔠 大写希腊字母:");
    let uppercase_greek = [
        "alpha_capital", "beta_capital", "gamma_capital", "delta_capital",
        "epsilon_capital", "zeta_capital", "eta_capital", "theta_capital",
        "iota_capital", "kappa_capital", "lambda_capital", "mu_capital",
        "nu_capital", "xi_capital", "omicron_capital", "pi_capital",
        "rho_capital", "sigma_capital", "tau_capital", "upsilon_capital",
        "phi_capital", "chi_capital", "psi_capital", "omega_capital"
    ];
    
    println!("   字母名称 -> 符号");
    for (i, char_name) in uppercase_greek.iter().enumerate() {
        if let Some(char) = unichar.get(char_name) {
            print!("   {:>15} -> {}  ", char_name, char);
            if (i + 1) % 3 == 0 {
                println!();
            }
        }
    }
    println!("\n");

    // 3. 数学中常用的希腊字母
    println!("3. 📐 数学中常用的希腊字母:");
    let math_greek = [
        ("alpha", "角度、系数"),
        ("beta", "角度、系数"),
        ("gamma", "角度、伽马函数"),
        ("delta", "变化量、判别式"),
        ("epsilon", "小量、误差"),
        ("theta", "角度、参数"),
        ("lambda", "特征值、波长"),
        ("mu", "平均值、微"),
        ("pi", "圆周率"),
        ("sigma", "标准差、求和"),
        ("phi", "角度、黄金比例"),
        ("omega", "角频率、集合")
    ];
    
    for (char_name, usage) in math_greek {
        if let Some(char) = unichar.get(char_name) {
            println!("   {} ({}) -> {}", char, char_name, usage);
        }
    }
    println!();

    // 4. 物理中常用的希腊字母
    println!("4. ⚛️ 物理中常用的希腊字母:");
    let physics_greek = [
        ("alpha", "角加速度"),
        ("beta", "相对论因子"),
        ("gamma", "相对论因子"),
        ("delta", "变化量"),
        ("epsilon", "介电常数"),
        ("theta", "角度"),
        ("lambda", "波长"),
        ("mu", "摩擦系数"),
        ("nu", "频率"),
        ("pi", "π介子"),
        ("rho", "密度"),
        ("sigma", "截面"),
        ("tau", "时间常数"),
        ("phi", "相位"),
        ("chi", "磁化率"),
        ("psi", "波函数"),
        ("omega", "角频率")
    ];
    
    for (char_name, usage) in physics_greek {
        if let Some(char) = unichar.get(char_name) {
            println!("   {} ({}) -> {}", char, char_name, usage);
        }
    }
    println!();

    // 5. 希腊字母别名演示
    println!("5. 🏷️ 希腊字母别名演示:");
    let aliases = [
        ("alpha_a", "α"),
        ("beta_b", "β"),
        ("gamma_g", "γ"),
        ("delta_d", "δ"),
        ("epsilon_e", "ε"),
        ("theta_th", "θ"),
        ("lambda_l", "λ"),
        ("mu_m", "μ"),
        ("pi_p", "π"),
        ("sigma_s", "σ"),
        ("phi_f", "φ"),
        ("omega_w", "ω")
    ];
    
    for (alias, _expected) in aliases {
        if let Some(char) = unichar.get(alias) {
            println!("   {} -> {} (别名)", alias, char);
        }
    }
    println!();

    // 6. 样式切换演示
    println!("6. 🎨 希腊字母样式切换演示:");
    let demo_letters = ["alpha", "beta", "gamma", "delta", "pi", "sigma", "omega"];
    
    for style in [Style::Simple, Style::Bold] {
        unichar.set_config(Config::new().with_style(style.clone()));
        print!("{:?}: ", style);
        for char_name in demo_letters {
            if let Some(char) = unichar.get(char_name) {
                print!("{} ", char);
            }
        }
        println!();
    }
    println!();

    // 7. 数学公式演示
    println!("7. 📝 数学公式演示:");
    unichar.set_config(Config::new().with_style(Style::Simple));
    
    let formulas = [
        "圆的面积: A = {pi} × r²",
        "波长公式: λ = c / f",
        "角度转换: {theta} = {alpha} + {beta}",
        "标准差: σ = √(Σ(x - μ)² / n)",
        "特征值: A{v} = λ{v}",
        "相位差: Δ{phi} = {omega} × t",
        "黄金比例: {phi} = (1 + √5) / 2"
    ];
    
    for formula in formulas {
        let result = unichar.format(formula);
        println!("   {}", result);
    }
    println!();

    // 8. 希腊字母统计
    println!("8. 📊 希腊字母统计:");
    let all_greek = [
        "alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta",
        "iota", "kappa", "lambda", "mu", "nu", "xi", "omicron", "pi",
        "rho", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega"
    ];
    
    let mut found_count = 0;
    for char_name in all_greek {
        if unichar.has_character(char_name) {
            found_count += 1;
        }
    }
    
    println!("   小写希腊字母: {} / {} 个", found_count, all_greek.len());
    
    let uppercase_count = uppercase_greek.len();
    let mut uppercase_found = 0;
    for char_name in uppercase_greek {
        if unichar.has_character(char_name) {
            uppercase_found += 1;
        }
    }
    
    println!("   大写希腊字母: {} / {} 个", uppercase_found, uppercase_count);
    println!("   总计希腊字母: {} 个", found_count + uppercase_found);
    
    println!("\n🎉 希腊字母演示完成！");
}
